package com.csnf.servlet;

import com.csnf.entity.Role;
import com.csnf.service.RoleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/role")
public class RoleServlet2 extends HttpServlet {
    RoleService  roleService= new RoleService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        List<Role> list = roleService.getRole();
        System.out.println(list);
        System.out.println("中文");
        req.setAttribute("roleList",list);
        req.getRequestDispatcher("login.jsp").forward(req,resp);
    }
}
